<template>
  <div>
    <h2>业户基础信息</h2>

    <h5>
      查询指定数据：<input type="text" v-model="searchCondition" placeholder="请输入查询地址">
      <el-button type="primary" @click="selectcondition">点击查询</el-button>
    </h5>

    <el-table :data="householdinformationList" style="width: 100%" border empty-text="暂无数据" >

      <el-table-column prop="ADDRESS" label="地址" width="180" />

      <el-table-column prop="CHARGERNAME" label="负责人姓名" width="180"/>

      <el-table-column prop="CONTACTER" label="联系人" width="180" />

      <el-table-column label="操作">
        <template #default="scope">
          <el-button type="success" @click="test(scope.row)">查看详细</el-button>
        </template>
      </el-table-column>
    </el-table>


    <el-dialog v-model="dialogVisible" title="详细信息" width="30%">
      <div style="text-align: left">
        地址:{{householdinformation.ADDRESS}}
        <br/>
        负责人姓名:{{householdinformation.CHARGERNAME}}
        <br/>
        联系人:{{householdinformation.CONTACTER}}
        <br/>
        创建时间:{{householdinformation.CREATETIME}}
        <br/>
        经济类型名称:{{householdinformation.ECONOMICTYPENAME}}
        <br/>
        法人身份证号:{{householdinformation.LEGALIDNUM}}
        <br/>
        法人身份证类型:{{householdinformation.LEGALIDNUMTYPE}}
        <br/>
        许可证号:{{householdinformation.LICENO}}
        <br/>
        经营单位代码:{{householdinformation.MANUNITCODE}}
        <br/>
        经营管理名称:{{householdinformation.OPERATERAHGEHAME}}
        <br/>
        经营单位名称:{{householdinformation.OPERATEUNITNAME}}
        <br/>
        所有者ID:{{householdinformation.AOWNERID}}
        <br/>
        所有者名称:{{householdinformation.OWNERNAME}}
        <br/>
      </div>
      <el-button  @click="addOne(householdinformation)">
        点击添加
      </el-button>
    </el-dialog>

  </div>
</template>

<script>
import axios from "axios";
import {ElMessage} from "element-plus";

export default {
  name: "HouseholdinformationView",
  data(){
    return {
      householdinformationList:[],
      dialogVisible:false,
      householdinformation:{},
      searchCondition:"",
    }
  },created() {
    axios("http://localhost:8000/consumerselect/householdinformation").then(
        (res)=>{
          this.householdinformationList = res.data;
          ElMessage.info("数据查询完成")
        }
    )
  },
  methods:{
    test(row){
      this.householdinformation = row;
      this.dialogVisible = true;
    },
    selectcondition(){
      axios(`http://localhost:8000/consumerselect/householdinformation?address=${this.searchCondition}`).then(
          (res)=>{
            this.householdinformationList = res.data
            ElMessage.info("条件查询完成")
          }
      )
    },
    addOne(row){
      alert("添加功能还未开放")
    }
  }
}
</script>

<style scoped>

</style>